Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2V] Remove fatal nil IP check in preflight check #18496

Merged

Conversation

ghost
Copy link

@ghost ghost commented Feb 27, 2019

We introduced a check on empty IP address for NICs. However, this should only apply to migrations to OpenStack as it only breaks network port creation. This PR relaxes the check to limit it to migrations toward OpenStack.

We introduced a check on empty IP address for NICs, because it made virt-v2v-wrapper fail when migrating to OpenStack. However, this was not limited to OpenStack and blocked migrations to RHV, so was too strict. Also, virt-v2v-wapper is able to handle NICs without IP address as long as the ip_address field is not part of the mapping we send to it. This PR removes the check on the IP address and removes the ip_address field if it's nil.

Associated RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1680487

@ghost
Copy link
Author

ghost commented Feb 27, 2019

@miq-bot add-label transformation, bug, hammer/yes
@miq-bot add-reviewer agrare, djberg96, jameswnl

@miq-bot
Copy link
Member

miq-bot commented Feb 27, 2019

@fdupont-redhat 'agrare, djberg96, jameswnl' is an invalid reviewer, ignoring...

@ghost
Copy link
Author

ghost commented Feb 27, 2019

@miq-bot add-reviewer agrare

@miq-bot miq-bot requested a review from agrare February 27, 2019 15:48
@ghost
Copy link
Author

ghost commented Feb 27, 2019

@miq-bot add-reviewer djberg96
@miq-bot add-reviewer jameswnl

@@ -459,7 +459,12 @@

it "fails if network IP address is nil" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to update this as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -459,7 +459,12 @@

it "fails if network IP address is nil" do
allow(src_nic_2).to receive(:network).and_return(src_network_2b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rename this src_network_2b to be something obvious e.g. nil_ip_network?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also renamed src_network_2a.

@agrare agrare self-assigned this Feb 27, 2019
Copy link
Member

@agrare agrare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this validation is openshift specific it should be extracted to the openshift repo in the openshift subclass

@@ -256,12 +256,12 @@ def calculate_network_mappings
source_network = nic.lan
destination_network = transformation_destination(source_network)
raise "[#{source.name}] NIC #{nic.device_name} [#{source_network.name}] has no mapping." if destination_network.nil?
raise "[#{source.name}] NIC #{nic.device_name} [#{source_network.name}] has an empty IP address." if nic.network.try(:ipaddress).nil?
raise "[#{source.name}] NIC #{nic.device_name} [#{source_network.name}] has an empty IP address." if nic.network.try(:ipaddress).nil? && destination_ems.emstype == 'openstack'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👎 really don't like hard coding this into the common base class

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation is specific to IMS. That's an IMS limitation due to the way CloudForms stores the IP addresses for a single NIC. When a NIC has a number of IPv4 or IPv6 addresses greater than 1, the Network object associated to the Nic object can have a nil IP address.

BTW, we also handle the various providers using send with method names including the provider name. How different is that ? Shoud I split network_mappings into network_mappings_rhevm and network_mappings_openstack ?

Copy link
Contributor

@djberg96 djberg96 Feb 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fdupont-redhat Let's create some scaffolding in the provider repo and put it there. I already have ServiceTemplateTransformationPlan at https://github.com/ManageIQ/manageiq-providers-openstack/blob/master/app/models/manageiq/providers/openstack/cloud_manager/service_template_transformation_plan.rb.

So, how about we create ServiceTemplateTransformationPlanTask there as well (in its own file), and then put our rules in there. Let's establish a common interface method. Then have the core method use that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bzwei and I looked around yesterday. I think this will "just work" if you subclass it and redefine it in the subclass, as rails should automagically set the type properly. @agrare am I wrong?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@djberg96 exactly as long as you actually have an instance of ManageIQ::Providers::Openstack::CloudManager::ServiceTemplateTransformationPlan it'll call into that method first.

Typically we'd define

def calculate_network_mappings
  super # call the base code
  additional_super_awesome_validations_only_for_openstack
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's some magic happening at https://github.com/ManageIQ/manageiq/blob/master/app/models/miq_request.rb#L341 inside MiqRequest, but I think it will still work.

I would normally call super, but since it's a loop, he might be better off just redefining the method completely, otherwise he'll have to loop again. That, or create some sort of common interface method for a validating check, but that's more work.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading virt-v2v-wrapper code, it appears that a missing IP address is not a problem. What fails is a IP address with nil value, as virt-v2v-wrapper will add the None literal to the openstack command. I discussed with Marco and he agreed that there are valid use cases for missing IP address, regardless of BZ#1657126, so we should not forcefully fail but rather prevent virt-v2v-wrapper failure. I updated the PR to reflect that and the network_mappings is again generic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR title and description.

@ghost ghost force-pushed the v2v_relax_empty_ip_check_for_rhv branch from 1b60ae0 to db92d3c Compare March 5, 2019 07:17
:ip_address => nic.network.ipaddress
}
:ip_address => nic.network.try(:ipaddress)
}.delete_if { |_, v| v.nil? }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hash#compact is simpler. :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.

@ghost ghost changed the title [V2V] Relax empty IP check when migrating to RHV [V2V] Remove fatal nil IP check in preflight check Mar 5, 2019
@miq-bot
Copy link
Member

miq-bot commented Mar 5, 2019

Checked commits fabiendupont/manageiq@a543ba9~...7d226da with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@agrare agrare merged commit 35f5025 into ManageIQ:master Mar 5, 2019
@agrare agrare added this to the Sprint 107 Ending Mar 18, 2019 milestone Mar 5, 2019
@ghost ghost deleted the v2v_relax_empty_ip_check_for_rhv branch March 5, 2019 21:12
simaishi pushed a commit that referenced this pull request Mar 6, 2019
…k_for_rhv

[V2V] Remove fatal nil IP check in preflight check

(cherry picked from commit 35f5025)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1686049
@simaishi
Copy link
Contributor

simaishi commented Mar 6, 2019

Hammer backport details:

$ git log -1
commit 213702bb40ca8a3bc47058dada9c415900412881
Author: Adam Grare <agrare@redhat.com>
Date:   Tue Mar 5 11:42:25 2019 -0500

    Merge pull request #18496 from fdupont-redhat/v2v_relax_empty_ip_check_for_rhv
    
    [V2V] Remove fatal nil IP check in preflight check
    
    (cherry picked from commit 35f50255759c523254c1a6e2d244eb420661c5cf)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1686049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants